package saati.core.concordance;

import java.util.List;

public abstract class AbstractConcordanceCalculator {
    protected int m;
    protected int n;
    protected int[][] rangeMatrix;

    public Double getConcordance(Double mathExp, List<Integer> summaryRangeList) {
        return calculate(calculateS(mathExp, summaryRangeList));
    }


    private Double calculateS(Double mathExp, List<Integer> summaryRangeList) {
        Double sum = 0d;
        for (int r : summaryRangeList) {
            sum += Math.pow(r - mathExp, 2);
        }
        return sum;
    }

    protected abstract Double calculate(Double s);

    public void setRangeMatrix(int[][] rangeMatrix) {
        this.rangeMatrix = rangeMatrix;
        this.n = rangeMatrix.length;
        this.m = rangeMatrix[0].length;
    }
}
